import { Controller, Get, Param, Query } from '@nestjs/common'
import { AzureAppOAuthService } from 'src/services/azure-app-oauth.service'

@Controller('azure-app-oauth')
export class AzureAppOAuthController {

  constructor(private readonly azureAppOAuthService: AzureAppOAuthService) { }

  // @Get('authorize/:clientId')
  // async authorize(@Param('clientId') clientId: string, @Res() res) {
  //   let url = await this.azureAppOAuthService.getAuthUrl(clientId)
  //   return res.redirect(url)
  // }

  @Get('authorize/callback/:clientId')
  public async callback(@Param('clientId') appCode: string, @Query('code') code: string) {
    return this.azureAppOAuthService.oauthCallback(appCode, code)
  }


}
